(function ($) {
    $.fn.objTurboMode = function (InIt) {

        var rdTurboMode;

        var controlMapExisting=new Array(0);
        var controlMapCurrent=new Array(0);

	var xmlName = '';

        var afterTurboRebootID;

	this.onLoad = function () {
            var index = 0;

	    this.loadHTML();

	    document.getElementById("title").innerHTML = jQuery.i18n.prop(InIt);
            var xml = getData(xmlName);

            var arrayLabels = document.getElementsByTagName("label");
            lableLocaliztion(arrayLabels);

            var buttonID = document.getElementById("btUpdate").id;
            buttonLocaliztion(buttonID);

	    var mode;

            mode=$(xml).find("turbo_mode").text();
            rdTurboMode.setRadioButton(mode);
            controlMapExisting = g_objXML.putMapElement(controlMapExisting,index++, "RGW/management/turbo_mode",mode);

            controlMapCurrent = g_objXML.copyArray(controlMapExisting,controlMapCurrent);

	}

	this.onPost  =  function  () {
            var _controlMap = this.getPostData();
            if(_controlMap.length>0) {
                postXML("admin", g_objXML.getXMLDocToString(g_objXML.createXML(_controlMap)));
            }
        }

	this.onPostSuccess = function (){
	    
	    var xml = getData("reset");

	    sm('MBConfirmTurbo',319,100);

	    document.getElementById("h1ConfirmTurbo").innerHTML = jQuery.i18n.prop("h1ConfirmTurbo");
	    document.getElementById("lConfirmText5").innerHTML = jQuery.i18n.prop("lConfirmText5");
	    document.getElementById("lConfirmText6").innerHTML = jQuery.i18n.prop("lConfirmText6");

	    afterTurboRebootID =  setInterval("afterReboot()", 25000);

        }

        this.afterReboot = function () {
            hm();
            clearInterval(afterTurboRebootID);
            clearAuthheader();
        }

        this.getPostData = function (){

            var index = 0;
            var mapData = new Array(0);

            controlMapCurrent[index++][1] = rdTurboMode.getRadioButton();

            mapData = g_objXML.copyArray(controlMapCurrent,mapData);
            mapData = g_objXML.getChangedArray(controlMapExisting,mapData,true);

	    return mapData;
        }

	this.setXMLName = function (_xmlname){
            xmlName = _xmlname;
        }

	this.loadHTML = function() {
	    document.getElementById('Content').innerHTML = "";
	    document.getElementById('Content').innerHTML = callProductHTML("html/router/turbo_mode.html");
            rdTurboMode = $("#rdTurboMode").enabled_disabled("rdTurboMode");
        }

        return this.each(function () {
        });

    }
})(jQuery);
